﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LF3.Moduls;
using CP.DBService;
using Oracle.ManagedDataAccess.Client;
using System.Data;

namespace LF3.Repositories
{
    public class Lf_Material_ConsumeRepository
    {
        DBHelper db = DBHelper.CreateInstance();
        //合金散料
        public IList<Lf_Material_Consume> GetMatConsume(string heatid)
        {
            return db.ExecuteObject<Lf_Material_Consume>(string.Format(@"select * from Lf_Material_Consume 
                                                where heatid = '{0}' and MATERIALDESC not like '%线%' 
                                                order by INSERT_TIME desc", heatid));
        }
        //喂丝
        public IList<Lf_Material_Consume> GetWSConsume(string heatid)
        {
            return db.ExecuteObject<Lf_Material_Consume>(string.Format(@"select * from Lf_Material_Consume 
                                                where heatid = '{0}' and MATERIALDESC like '%线%'  
                                                order by INSERT_TIME desc", heatid));
        }

        public IList<Lf_Material_Info> GetMatInfo()
        {
            return db.ExecuteObject<Lf_Material_Info>("select * from lf_material_info order by BUNKERNO desc ,materialcode ");
        }

        public IList<Lf_Material_Info> GetWireInfo()
        {
            return db.ExecuteObject<Lf_Material_Info>("select * from lf_material_info where MATERIALDESC like '%线%' order by materialcode");
        }

        public IList<Lf_Set_Wire> GetWires()
        {
            return db.ExecuteObject<Lf_Set_Wire>("select * from lf_set_wire  order by pipe_no");
        }

        public void SetPipeWire(Lf_Set_Wire wire)
        {
            db.ExecuteNonQuery(string.Format(@"update lf_set_wire set 
                                mat_id = '{0}',mat_name='{1}' where pipe_no = '{2}'", 
                                               wire.mat_id, wire.mat_name, wire.pipe_no));
        }

    }
}
